Skip to content

feat(pnfs): implement the warm-standby metadata server - #767

Merged
boddumanohar merged 7 commits into
mainfrom
impl/pnfs-mds-standby
Nov 24, 2026
Merged

boddumanohar merged 7 commits into
mainfrom
impl/pnfs-mds-standby

Conversation

@boddumanohar

@boddumanohar boddumanohar commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Implements the warm-standby pNFS metadata server from operator/docs/designs/design-pnfs-mds-standby.md (#741). Losing the active metadata server now costs a promotion of a standby that is already running, not a pod restart on another node.

The guest image side is simplyblock/vela-os#30 (merged into pnfs-minimal): guests boot as standbys with no state disk, and nfsd starts only after mds-agent has promoted the guest.

Changes

API

  • spec.pnfs.mds.standbys (0 to 4, default 1): standby guests beside the active, each on its own KVM-capable node. It replaces stateSize and stateStorageClassName. The chart passes driver.pnfs.mds.standbys through.

Workload (operator)

  • The metadata server is a StatefulSet of 1 + standbys pods, one per KVM node, with no state disk in the pod.
  • The state coordinator (internal/mdsstate) keeps three things in line for each storage cluster:
    • the state volume, which holds the NFS client-recovery database and lives in the first export's pool;
    • each volume's allowed hosts, limited to the StatefulSet's host NQNs;
    • the StatefulSet's scale. A scale-down first moves the active to an ordinal that stays.

Takeover (operator, internal/mdsfailover)

  • Detects a lost active. A deleted pod counts at once. A pod whose node is not ready and whose session is gone counts after a 20 s window.
  • Writes the new active and epoch on the StatefulSet before acting, then calls Promote on the lowest-ordinal ready standby.
  • Points the Service's EndpointSlice at the new active, and holds NFSExport bindings until the new active serves them.
  • Demotes a returning old active: an instance the record does not name that still reports the active role.
  • Rolls a template change one guest at a time: standbys first, the active last.

Guest agent (CSI driver)

  • mds-agent serves MDSService (Describe, Promote) and the standard gRPC health check. mds-runner relays both and registers the guest as its pod.
  • A promotion runs in this order:
    1. Connect the state volume and every export.
    2. Fence each device with an NVMe persistent reservation, using a key derived from the StatefulSet UID and the epoch (register, then preempt-and-abort).
    3. Mount the devices.
    4. Set nfsd.pnfs_mds_pr_key.
    5. Create /run/mds/active, which lets the nfsd units start.
  • CreateExport is refused on a guest that is not active. A new export on the active guest is fenced before it is created.
  • A path keeper reconnects the export namespaces on every path the control plane published.

atlas-lib

  • nvmepr: NVMe persistent reservations on a namespace (register, reserve, preempt, preempt-and-abort, report), with an in-memory target (nvmeprtest) for tests.
  • internal/nvmepassthru: the passthrough command shared by nvme and nvmepr. A command the controller rejects is now returned as an error, where before it read as success.
  • nfsexport: metadata server reservation keys (MDSReservationKey, ParseMDSKey, IsMDSKey).
  • nfsexportrpc: the MDSService wire contract.
  • controlplane: add and remove a volume's allowed hosts.

Test framework

  • sbtest: chaos restarts tell the active MDS apart from its standbys. The reservation detector treats every MDS-range key as the server's. The metadata workload pins pods by full node name.

Testing

  • Unit and envtest suites for mdsfailover, mdsstate, the controller, the driver controller, the mds agent and relay, and atlas-lib nvmepr, nvmepassthru, and nvme. The Linux-only packages ran in a golang:1.26.10 container.
  • make lint: 0 issues. make -C operator manifests generate, make helm-sync, and build-installer produce no diff.
  • Live testing on a three-storage-node cluster with standbys: 2, an RWX export, and fio with crc32c verification on two client nodes:
    • Active pod deleted: the lowest-ordinal ready standby is promoted at the next epoch, the EndpointSlice follows, clients reclaim and the grace period ends early, with no fio error.
    • The reservation report shows only the new epoch's key after each takeover.
    • Kubelet stopped on the active's node with the guest alive: no takeover.
    • The active's node lost: exactly one of the two standbys is promoted, the other keeps the standby role, and the returning old active boots as a standby.
    • standbys changed 2 → 0 → 1 → 0 → 2: a scale-down with the active on ordinal 1 first moves it to ordinal 0.
    • The live run found that the agent tracked the state volume under a name rather than its mount directory, so the health check failed and the runner restarted the active every 90 s. Fixed in this PR, with a regression test.

Takeover time

How long clients go without I/O when the metadata server is lost. A probe on each client node issued a 4 KiB O_DSYNC write every 50 ms and logged every stall over 200 ms; node clocks were NTP-synced. Three runs per fault, compared with a single metadata server on main on another cluster of the same shape.

Fault This PR (standbys: 2) main (single MDS)
Active pod deleted 3.2 s, 4.8 s, 3.2 s 20.5 s, 28.3 s, 28.0 s
Guest crash (kill -9 qemu) 17.1 s, 11.2 s, 24.1 s 15.9 s, 27.5 s, 45.8 s
Errors returned to the client none EACCES for ~6 s after a delete, EIO after a crash

A deleted pod is promoted within 0.7–1.5 s. A crashed guest is promoted once its pod restarts and the guest reports the standby role, so its time follows the container restart and its back-off.

Base automatically changed from design/pnfs-mds-standby to main November 11, 2026 11:33
boddumanohar added a commit to simplyblock/vela-os that referenced this pull request Nov 11, 2026
Guest image side of the warm-standby metadata server
(simplyblock/simplyblock-operator#767). A guest boots with no state disk and
no nfsd; mds-agent fences the devices, mounts the state volume, sets the
reservation key, and only then lets nfsd start.

- Kernel patch 0025: nfsd.pnfs_mds_pr_key lets a metadata server instance
  register under a reservation key of its own and serve only the devices it
  holds.
- Kernel patch 0024: xfs.pnfs_discarded_free_space skips zeroing free space
  for write layouts once discarded blocks read as zeros.
- No state disk fstab entry; nfs-server, nfs-mountd, and nfsdcld wait for
  /run/mds/active, which mds-agent creates on promotion.
- CI: only main and pnfs-minimal move the shared pnfsos tags; other branches
  push commit-pinned tags.

Co-authored-by: Christoph Engelbert (noctarius) <me@noctarius.com>
@boddumanohar
boddumanohar force-pushed the impl/pnfs-mds-standby branch 2 times, most recently from 5c7d5ee to 626c5ac Compare November 11, 2026 12:32
The pNFS metadata server runs as a StatefulSet of one active QEMU guest and
spec.pnfs.mds.standbys warm standbys (default 1, at most 4), each on its own
KVM node, so the loss of the active costs a promotion instead of a restart.

- API: spec.pnfs.mds.standbys replaces stateSize and stateStorageClassName.
  Guests boot with no state disk, as standbys.
- mds-agent serves MDSService (Describe, Promote), relayed by the runner. A
  promotion connects the state volume and every export, fences each device
  with an NVMe persistent reservation keyed by StatefulSet UID and epoch
  (register, then preempt-and-abort), mounts, and only then lets nfsd start.
- The operator detects a lost active (pod deleted, or node and session gone
  for 20 s), writes the new active and epoch on the StatefulSet before acting,
  promotes the lowest-ordinal ready standby, repoints the Service, and demotes
  a returning old active.
- The state coordinator keeps the state volume, each volume's allowed hosts,
  and the StatefulSet's scale; a scale-down moves the active to a lower
  ordinal first, and a template change rolls standbys before the active.
- atlas-lib: nvmepr (persistent reservations), nvmepassthru, MDS reservation
  keys, and volume allowed-hosts calls on the control-plane client.
- CI pins the MDS guest image built from vela-os#30 (revert before merge).
@boddumanohar
boddumanohar marked this pull request as ready for review November 19, 2026 15:52
Comment thread atlas-lib/nfsexport/mdskey.go Resolved
Comment thread atlas-lib/nvmepr/nvmeprtest/target.go Resolved
Comment thread atlas-lib/nvmepr/linux.go Resolved
Comment thread csi-driver/cmd/mds-agent/main.go Resolved
Comment thread operator/internal/mdsstate/names.go Resolved
…mmands

A general Run let any atlas-lib caller send an arbitrary NVMe command
through the ioctl. The namespace ID and the Reservation Report are now
unexported in nvmepr, its only user.
…the test doubles test

The MDS StatefulSet's annotations and finalizer join the other
storage.simplyblock.io keys in atlas-lib/kube. The in-memory doubles
nvmepr/nvmeprtest and mdsstate/mdsstatetest become nvmepr/test and
mdsstate/test.
mdsfailover.Ordinal and utils.MDSStatefulSetNameOfPod parsed the same
<statefulset>-<ordinal> name with different checks: Ordinal read 1 from
"-1" and 5 from "mds-+5", which the other refused. Both now go through
utils.SplitMDSPodName, which returns the ordinal as an int32.
@boddumanohar
boddumanohar merged commit dc37e7d into main Nov 24, 2026
27 checks passed
@boddumanohar
boddumanohar deleted the impl/pnfs-mds-standby branch November 24, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants